#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "personnel.h"


void
on_button2_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button3_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button4_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button5_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
gtk_main_quit();
}


void on_button1_clicked (GtkWidget       *button,
                                        gpointer         user_data)
{
                GtkWidget *window2;
                GtkWidget *window1;                
                window1 = lookup_widget(button,"window1");
                gtk_widget_hide(window1);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void
on_button6_clicked                     (GtkWidget       *button,
                                        gpointer         user_data)
{                GtkWidget *window2;
                 window2 = lookup_widget(button,"window2");
                 GtkWidget *window3;
                  gtk_widget_hide(window2);
                 window3 = create_window3();
		 gtk_widget_show(window3);
}


void
on_button7_clicked                     (GtkWidget       *button,
                                        gpointer         user_data)
{                GtkWidget *window2;
                 window2 = lookup_widget(button,"window2");
                 
                 gtk_widget_hide(window2);
                GtkWidget *window4;
                window4 = create_window4();
		gtk_widget_show(window4);
}


void
on_button8_clicked                     (GtkWidget       *button,
                                        gpointer         user_data)
{
                
                 GtkWidget *window2;
                 window2 = lookup_widget(button,"window2");
                 gtk_widget_hide(window2);
                GtkWidget *window5;
                window5 = create_window5();
		gtk_widget_show(window5);
}


void
on_button9_clicked                     (GtkWidget       *button,
                                        gpointer         user_data)
{                 
                  GtkWidget *window2;
                     window2 = lookup_widget(button,"window2");
                gtk_widget_hide(window2);
                GtkWidget *window6;
                window6 = create_window6();
		gtk_widget_show(window6);
}


void
on_button10_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{



}


void
on_button11_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{


}


void
on_button14_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button15_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button16_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button17_clicked                    (GtkWidget *objet_graphique, gpointer user_data)

{


        personnel p;
	char fichier[] = "fichierpersonnel.txt";

	GtkWidget *entry3;
	GtkWidget *entry4;
	GtkWidget *entry9;
        GtkWidget *entry5;
	GtkWidget *entry8;
	GtkWidget *entry7;
        GtkWidget *entry6;
        
        entry3 = lookup_widget(objet_graphique, "entry3");
	entry4 = lookup_widget(objet_graphique, "entry4");
	entry9 = lookup_widget(objet_graphique, "entry9");
        entry5 = lookup_widget(objet_graphique, "entry5");
	entry8 = lookup_widget(objet_graphique, "entry8");
	entry7 = lookup_widget(objet_graphique, "entry7");
        entry6 = lookup_widget(objet_graphique, "entry6");


	
	strcpy(p.nom, gtk_entry_get_text(GTK_ENTRY(entry3)));
	strcpy(p.prenom, gtk_entry_get_text(GTK_ENTRY(entry4)));
	p.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry9)));
        p.cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry5)));
        strcpy(p.mail, gtk_entry_get_text(GTK_ENTRY(entry8)));
        strcpy(p.id, gtk_entry_get_text(GTK_ENTRY(entry7)));
        p.number = atoi(gtk_entry_get_text(GTK_ENTRY(entry6)));
      
       
          Enregistrer_Personnel(fichier,p) ;
        
        

        
        
}


void
on_button18_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{

}


void
on_button19_clicked                    (GtkWidget *objet_graphique, gpointer user_data)
{           

         
                 


int i=0;
 
    
                personnel p;
	char fichier[] = "fichierpersonnel.txt";


	char Buf0[200] = "NOM: ";
	char Buf1[50] = "PRENOM: ";
	char Buf2[50] = "AGE: ";
	char Buf3[50] = "CIN: " ;
	char Buf4[50] = "MAIL: ";
        char Buf5[200] = "IDENTIFIANT: ";
	char Buf6[50] = "NUMBER: ";
	char Buf7[300] ;

	GtkWidget *label18;

	label18= lookup_widget(objet_graphique, "label18");

	lire_personnel(fichier,&p) ;
           i++ ;

	sprintf(Buf7, " \n Personnel %d: %s %s  %s %s  %s %d  %s %ld  %s %s  %s %s  %s %ld \n", i, Buf0, p.nom, Buf1,p.prenom, Buf2, p.age,Buf3,p.cin,Buf4,p.mail,Buf5,p.id,Buf6,p.number);

	gtk_label_set_text(GTK_LABEL(label18), Buf7);

}



void
on_button20_clicked                    (GtkWidget       *button,
                                        gpointer         user_data)
{              
                 GtkWidget *window2;
                 GtkWidget *window1;                
                 window2 = lookup_widget(button,"window2");
                 gtk_widget_hide(window2);
                 window1 = create_window1();
		 gtk_widget_show(window1);
}



void
on_button21_clicked                    (GtkWidget       *button,
                                        gpointer         user_data)
{
                 GtkWidget *window3;
                 GtkWidget *window2;                
                 window3 = lookup_widget(button,"window3");
                 gtk_widget_hide(window3);
                 window2 = create_window2();
		 gtk_widget_show(window2);
}


void
on_button22_clicked                    (GtkWidget       *button,
                                        gpointer         user_data)
{
                 GtkWidget *window4;
                 GtkWidget *window3;                
                 window4 = lookup_widget(button,"window4");
                 gtk_widget_hide(window4);
                 window3 = create_window3();
		 gtk_widget_show(window3);
}



void
on_button23_clicked                    (GtkWidget       *button,
                                        gpointer         user_data)
{
                 GtkWidget *window5;
                 GtkWidget *window4;                
                 window5 = lookup_widget(button,"window5");
                 gtk_widget_hide(window5);
                 window4 = create_window4();
		 gtk_widget_show(window4);
}



void
on_button24_clicked                    (GtkWidget       *button,
                                        gpointer         user_data)
{
                 GtkWidget *window6;
                 GtkWidget *window5;                
                 window6 = lookup_widget(button,"window6");
                 gtk_widget_hide(window6);
                 window5= create_window5();
		 gtk_widget_show(window5);
}

